package com.heima.article.controller.v1;

import com.heima.article.service.ArticleService;
import com.heima.model.article.constants.ArticleConstants;
import com.heima.model.article.dtos.Articleload;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    //登录后默认加载
    @PostMapping("/load")
    public ResponseResult load(@RequestBody Articleload articleload){
        //return articleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,articleload);
        return articleService.load2(ArticleConstants.LOADTYPE_LOAD_MORE,articleload);
    }

    //下拉加载最新新闻
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody Articleload articleload){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,articleload);
    }

    //上拉加载更多
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody Articleload articleload){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,articleload);
    }
}
